package com.forekonw.demo11;

import java.util.*;

public class demotest1104 {
    public static void main(String[] args) {
        Person p1 = new Person();
        Person p2 = new Person();
        Person p3 = new Person();
        Person p4 = new Person();
        Person p5 = new Person();
        Person p6 = new Person();
        p1.setName("tom");
        p2.setName("tony");
        p3.setName("jim");
        p4.setName("tanxin");
        p5.setName("hongzu");
        p6.setName("junqiao");
        /**
         * * 创建一个List集合，
         *  * 向集合List存三个Map每个对象有两个对象Person，
         *  * 把所有人都显现出来
         */
//先建3个容器map
        Map<Integer,Person> m1 = new HashMap<>();
        Map<Integer,Person> m2 = new HashMap<>();
        Map<Integer,Person> m3 = new HashMap<>();
        m1.put(1,p1);
        m1.put(2,p2);
        m2.put(1,p3);
        m2.put(2,p4);
        m3.put(1,p5);
        m3.put(2,p6);
        //建一个list容器
        List<Map<Integer,Person>> lm = new ArrayList<>();
        lm.add(m1);
        lm.add(m2);
        lm.add(m3);
        //遍历list以及map
        Iterator<Map<Integer,Person>> ll = lm.iterator();
        while (ll.hasNext()){
            Map<Integer,Person> mp = ll.next();
            Set<Map.Entry<Integer,Person>> ss = mp.entrySet();
            Iterator<Map.Entry<Integer,Person>> sss = ss.iterator();
            while (sss.hasNext()){
                Map.Entry<Integer,Person> mm1 = sss.next();
                Person pp = mm1.getValue();
                System.out.println(pp.getName());
            }

        }
//        for (Map<Integer,Person>  mm: lm) {
//            Set<Map.Entry<Integer,Person>> sm = mm.entrySet();
//           Iterator<Map.Entry<Integer,Person>> ip = sm.iterator();
//           while (ip.hasNext()){
//               Map.Entry<Integer,Person> mm1 = ip.next();
////               Integer aa = mm1.getKey();
//               Person pp = mm1.getValue();
//               System.out.println(pp.getName());
//           }
        }
    }
